<!DOCTYPE html>
<!--suppress ALL-->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>查询我的房源发布信息页</title>
    <link rel="stylesheet" th:href="@{/assets/css/styles.css}">
    <link rel="stylesheet" th:href="@{/assets/css/colors.css}">
    <script th:src="@{/assets/js/jquery.min.js}"></script>
    <script th:src="@{/assets/js/popper.min.js}"></script>
    <script th:src="@{/assets/js/bootstrap.min.js}"></script>
    <script th:src="@{/assets/js/custom.js}"></script>
    <script th:src="@{/assets/js/daterangepicker.js}"></script>
    <script th:src="@{/assets/js/dropzone.js}"></script>
    <script th:src="@{/assets/js/imagesloaded.js}"></script>
    <script th:src="@{/assets/js/ion.rangeSlider.min.js}"></script>
    <script th:src="@{/assets/js/jquery.magnific-popup.min.js}"></script>
    <script th:src="@{/assets/js/lightbox.js}"></script>
    <script th:src="@{/assets/js/markerclusterer.js}"></script>
    <script th:src="@{/assets/js/moment.min.js}"></script>
    <script th:src="@{/assets/js/morris.min.js}"></script>
    <script th:src="@{/assets/js/raphael.min.js}"></script>
    <script th:src="@{/assets/js/select2.min.js}"></script>
    <script th:src="@{/assets/js/slick.js}"></script>
    <script th:src="@{/assets/js/slider-bg.js}"></script>
</head>
<body>
    <!-- 复用首页头部 -->
    <header th:replace="index::header"></header>
    <!-- 提示框信息 -->
    <div th:replace="point-modal::modal"></div>
    <!-- 当前用户发布的所有房源信息 -->
    <div class="container" style="margin-bottom: -20px; height: 695px; overflow: auto">
        <section class="p-0">
            <div class="container-fluid p-0">
                <div class="row">
                    <!-- 左侧导航栏 -->
                    <div th:replace="sidebar::left"></div>
                    <!-- 右侧内容 -->
                    <div class="col-lg-9 col-md-8 col-sm-12"  style="height:695px;overflow:auto;">
                        <div class="dashboard-body">
                            <div class="frm_submit_block" th:if="${loginUserData.role == 'manager'}">
                                <h4>房源管理</h4>
                            </div>
                            <div class="frm_submit_block" th:if="${loginUserData.role == 'owner'}">
                                <h4>我的房源</h4>
                            </div>
                            <!-- 房子信息展示（需要遍历循环） -->
                            <div class="row" th:if="${code==200}" style="margin-top: -20px; margin-bottom: -70px">
                                <div class="col-lg-4" th:each="map:${houses}">
                                    <div class="dashboard_property_list">
                                        <div class="dashboard_property_list_thumb">
                                            <img th:src="@{|/assets/img/house/${map.thumbnailUrl == null || map.thumbnailUrl == ''?'1.jpg':map.thumbnailUrl}|}" class="img-fluid">
                                            <!-- 需选择c:choose标签（添加样式：已出租published、已下架/待审核/审核不通过 expire，最后再加一个未知状态） -->
                                            <span th:switch="${map.status}">
                                                <span class="dashboard_pr_status" th:case="0">未出租</span>
                                                <span class="dashboard_pr_status published" th:case="1">已出租</span>
                                                <span class="dashboard_pr_status expire" th:case="-1">已下架</span>
                                                <span class="dashboard_pr_status expire" th:case="-2">待审核</span>
                                                <span class="dashboard_pr_status expire" th:case="-3">审核驳回</span>
                                                <span class="dashboard_pr_status" th:case="*">未知状态</span>
                                            </span>
                                        </div>
                                        <div class="dashboard_property_list_content">
                                            <h4 th:text="${map.title}">房子标题</h4>
                                            <span th:text="${map.address}" style="white-space: nowrap;"><i class="ti-location-pin"></i>房子地址显示</span>
                                        </div>
                                        <div class="dashboard_property_list_footer">
                                            <!-- 多选框 -->
                                            <a th:href="@{|/houseDetail/${map.id}|}" title="查看">&nbsp;<i class="ti-eye"></i>&nbsp;</a>
                                            <!-- 已租出的房子无法修改信息 -->
                                            <a th:href="@{/turnUpdateInfoPage(houseId=${map.id})}" title="编辑" th:if="${loginUserData.role == 'owner' && map.status!=1}">&nbsp;<i class="ti-pencil"></i>&nbsp;</a>
                                            <a th:href="@{/upHouse(houseId=${map.id})}" title="上架" th:if="${loginUserData.role == 'owner' && map.status==-1}">&nbsp;<i class="ti-control-play"></i>&nbsp;</a>
                                            <a th:href="@{/downHouse(houseId=${map.id})}" title="下架" th:if="${loginUserData.role == 'owner' && (map.status==0 || map.status==1)}">&nbsp;<i class="ti-control-pause"></i>&nbsp;</a>
                                            <a th:if="${loginUserData.role == 'owner'}" th:href="@{/deleteHouse(houseId=${map.id})}" title="删除">&nbsp;<i class="ti-close"></i>&nbsp;</a>
                                            <!-- 如果是管理员，还可以点击审核通过按钮 -->
                                            <a th:href="@{/manager/passAudit(houseId = ${map.id})}" title="审核通过" th:if="${loginUserData.role == 'manager' && map.status == -2}">&nbsp;<i class="ti-arrow-up"></i>&nbsp;</a>
                                            <a th:href="@{/manager/unPassAudit(houseId = ${map.id})}" title="审核驳回" th:if="${loginUserData.role == 'manager' && map.status == -2}">&nbsp;<i class="ti-arrow-down"></i>&nbsp;</a>
                                            <a th:href="@{/manager/upHouse(houseId=${map.id})}" title="上架" th:if="${loginUserData.role == 'manager' && map.status==-1}">&nbsp;<i class="ti-control-play"></i>&nbsp;</a>
                                            <a th:href="@{/manager/downHouse(houseId=${map.id})}" title="下架" th:if="${loginUserData.role == 'manager' && (map.status==0 || map.status==1)}">&nbsp;<i class="ti-control-pause"></i>&nbsp;</a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!-- 分页 -->
                            <nav class="mt-5" th:if="${page.rows>0}" th:replace="index::pagination"></nav>
                        </div>
                    </div>

                </div>
            </div>
        </section>
    </div>

    <!-- 复用首页底部 -->
    <div th:replace="index::footer"></div>

    <script th:inline="javascript">
        $(function () {
            $("#myHousesInfo").attr("class", "active");
            $("#HousesManage").attr("class", "active");
            var info = [[${msg}]];
            if(info != null && info != undefined && info != '') {
                $("#myModalBody").text(info);
                $("#myModal").prop("hidden", "");
                setTimeout(function () {
                    $("#myModal").prop("hidden", "hidden");
                }, 1000);
            }
        })
    </script>
</body>
</html>